﻿using Nirvana;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class TestI18N : MonoBehaviour
{
    [SerializeField]
    private Text scriptText;

    // Start is called before the first frame update
    void Start()
    {
        //List<UnityEngine.Object> objectsInScene = new List<UnityEngine.Object>();

        //foreach (UnityEngine.Object go in Resources.FindObjectsOfTypeAll(typeof(UnityEngine.Object)) as UnityEngine.Object[])
        //{
        //    GameObject cGO = go as GameObject;
        //    if (cGO != null && !EditorUtility.IsPersistent(cGO.transform.root.gameObject) && !(go.hideFlags == HideFlags.NotEditable || go.hideFlags == HideFlags.HideAndDontSave))
        //        objectsInScene.Add(go);
        //}

        //foreach(var p in objectsInScene)
        //{
        //    Debug.Log(p.name);
        //}

        scriptText.text = "初始文本";
    }

    public void OnLanguageChange()
    {
        if(I18N.Language == I18NLanguageType.En) scriptText.text = "Script contorl this Text";
        else scriptText.text = "脚本控制的文本";
        Debug.Log("------->>>"+ scriptText.text);
    }

    public void SetZWLanguage()
    {
        SetLanguage(I18NLanguageType.ZhChs);
    }

    public void SetEnLanguage()
    {
        SetLanguage(I18NLanguageType.En);
    }
    private void SetLanguage(I18NLanguageType languageType)
    {
        I18N.Language = languageType;
    }

}
